﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AzureToolkit.Engine
{
    internal class JobSchedule : JobScheduleBase
    {
        CrontabSchedule crontabSchedule;

        public JobSchedule(CrontabSchedule crontabSchedule, Type type) {
            this.type = type;
            this.crontabSchedule = crontabSchedule;
            this.nextRunTime = this.crontabSchedule.GetNextOccurrence(DateTime.UtcNow);
            this.lastRunTime = DateTime.UtcNow;
        }

        public override void Increment() {
            this.lastRunTime = this.nextRunTime;
            this.nextRunTime = this.crontabSchedule.GetNextOccurrence(this.nextRunTime);
        }
    }
}
